package com.cupster.dbflow4_2_4;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.cupster.func_db_dbflow.db_main.crud.UserHelper;
import com.cupster.func_db_dbflow.db_main.table.User;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    TextView mTv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mTv= findViewById(R.id.tv);
        findViewById(R.id.btn_add).setOnClickListener(this);
        findViewById(R.id.btn_delete).setOnClickListener(this);
        findViewById(R.id.btn_update).setOnClickListener(this);
        findViewById(R.id.btn_query).setOnClickListener(this);
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btn_add:
                UserHelper.insert("Cupster");
                break;
            case R.id.btn_delete:
                UserHelper.delete("Cupster");
                break;
            case R.id.btn_update:
                UserHelper.update("Cupster_Change" ,"Cupster");
                break;
            case R.id.btn_query:
                String s = UserHelper.selectUserList();
                mTv.setText(s);
                break;
        }

    }
}